<template>
  <div class="my-wrap">
    <div class="my-info">
      <div class="edit" @click="linkTo('editInfo')">
        <div class="edit-icon"></div>
      </div>
      <div class="avatar"><img :src="infoObj.images&&infoObj.images.length>0?infoObj.images[0].fileUrl:'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3987166397,2421475227&fm=27&gp=0.jpg'" alt=""></div>
      <div class="name">{{infoObj.trueName?infoObj.trueName:infoObj.userName}}</div>
      <div class="profession">{{infoObj.duty?dutyStr(infoObj.duty):' '}}</div>
      <div v-if="infoObj.mobile" class="telephone">手机号：{{infoObj.mobile?infoObj.mobile:''}}</div>
    </div>
    <div class="my-item">
      <div class="my-list box box-align-center" @click="linkTo('myCertification')">
        <div class="icon"></div>
        我的认证
      </div>
      <div class="my-list box box-align-center"  @click="linkTo('myCode')">
        <div class="icon"></div>
        我的二维码
      </div>
      <div class="my-list box box-align-center"  @click="linkTo('feedback')" >
        <div class="icon"></div>
        意见反馈
      </div>
      <div class="my-list box box-align-center"  @click="linkTo1('changePassword')" >
        <div class="icon"></div>
        设置
      </div>
    </div>
    <div @click="loginOut" class="my-btn">退出登录</div>
    <menu-list></menu-list>
  </div>
</template>
<script>
import menuList from '../common/navbar-menu'
let CONSTANT = require('../../../wechat/static/constant/constant.js'),
    common = require("../../../wechat/static/common/common.js"),
    wsService = require("../../../wechat/static/common/wechat-jsdk.js");
  export default {
    data() {
      return {
        list:'',
        infoObj:'',
        identifyList: [
          {key: "doctor", value:"医生"},{key: "nurse", value:"护士"},{key: "recover_physical_therapist", value:"康复理疗师"},
          {key: "health_manager", value:"健康管理师"},{key: "apothecary", value:"药师"},{key: "hospital ", value:"医院"},{key: "clinic", value:"诊所"},
          {key: "drugstore", value:"药店"},{key: "medical_instrument_supplie", value:"医疗器械供应商"},
        ],
        stateTatus:false
      }
    },
    components: {
      menuList
    },
    mounted() {
      this.getInfo()
      this.getState()
    },
    methods: {
      linkTo(link){
        if(!this.stateTatus ||  this.stateTatus == 'n'){
           this.$router.push('/certificateEdit')
           return;
        }
        if(this.stateTatus == 'w'){
           this.$router.push('/myCertification')
           return;
        }
        console.log(this.stateTatus)
        if(link == 'myCode'){
         this.$router.push(`${link}?name=${this.infoObj.trueName?this.infoObj.trueName:this.infoObj.userName}&title=${this.infoObj.title?this.infoObj.title:''}&avatar=${this.infoObj.images.length?this.infoObj.images[0].fileUrl:''}`)
         return;
        }
        this.$router.push(link)
      },
      linkTo1(link){
        this.$router.push(link)
      },
      getState(){
        let  url = CONSTANT.URL.DOCTOR.CHECKDETAIL,
            param = {}
        common.requestAjax(url,{},param,(res)=>{
            if(res.status == 200){
                let data = res.data.bussData;
                if(res.data.bussData){
                  this.stateTatus = res.data.bussData.auditStatus
                }
            }else{

            }
        })
      },
      dutyStr(e){
          let str;
          this.identifyList.forEach((item)=>{
              if(item.key == e){
                  str = item.value
              }
          })
         return str;
      },
      getInfo(){
        let  url = CONSTANT.URL.DOCTOR.DETAIL,
            param = {}
        common.requestAjax(url,{},param,(res)=>{
            if(res.status == 200){
                let data = res.data.bussData;
                this.infoObj = data;
                console.log(data)
            }else{

            }
        })
      },
      loginOut(){
        let that = this;
        this.$vux.confirm.show({
          content: '是否退出登录?',
          onShow () {
            console.log('plugin show')
          },
          onHide () {
            console.log('plugin hide')
          },
          onCancel () {
            console.log('plugin cancel')
          },
          onConfirm () {
            let  url = CONSTANT.URL.LOGIN.LOGOUT,
            param = {}
            common.requestAjax(url,{},param,(res)=>{
              that.$router.replace('/login')
            })

          }
        })
      }

    }
  };
</script>
<style lang="less">
  .my-wrap {
    height: 85%;
    padding-top: 15%;
    background-color: #f4f4f4;
    .my-info{
      position: relative;
      background-color: #fff;
      width: 6.9rem;
      height: 3rem;
      border-radius: 10px;
      -webkit-border-radius: 10px;
      box-shadow: 1px 1px 5px  rgba(0, 0, 0, .09);
      margin: 0 auto .4rem;
      font-size: .3rem;
      color: #333;
      text-align: center;
      .edit{
          position: absolute;
          right: 0rem;
          top: .3rem;
          width: .82rem;
          height: .82rem;
          .edit-icon{
            background-image: url(../../images/edit.png);
            background-size:100%;
            width: .32rem;
            height: .34rem;
          }
      }
      .avatar{
        position: absolute;
        left: 2.65rem;
        top: -.9rem;
        img{
          width: 1.61rem;
          height: 1.61rem;
          border-radius: 50%;
          -webkit-border-radius: 50%;
        }
      }
      .name{
        font-size: .34rem;
        color: #111;
        padding-top: 11%;
      }
      .profession{
        margin: .05rem 0 .2rem;
        height: .4rem;
      }
    }
    .my-item{
      background-color: #fff;
      border-radius: 10px;
      -webkit-border-radius: 10px;
      box-shadow: 1px 1px 5px  rgba(0, 0, 0, .09);
      width: 6.9rem;
      margin:  0 auto;
      .my-list{
        height: 1.16rem;
        font-size: .34rem;
        margin: 0 .31rem 0 .29rem;
        color: #333;
        border-bottom: 1px solid #DEDEDE;
        .icon{
          background-image: url(../../images/me1.png);
          background-size:100%;
          width: .43rem;
          height: .45rem;
          margin-right: .26rem;
        }
        &:nth-child(2){
          .icon{
            background-image: url(../../images/me2.png);
            width: .37rem;
            height: .37rem;
            margin-right: .27rem;
          }
        }
        &:nth-child(3){
          .icon{
            background-image: url(../../images/me3.png);
            width: .38rem;
            height: .40rem;
            margin-right: .23rem;
          }
        }
        &:nth-child(4){
          .icon{
            background-image: url(../../images/me4.png);
            width: .38rem;
            height: .37rem;
          }
          border-bottom: 0;
        }
      }
    }
    .my-btn{
      width: 6.9rem;
      height: .88rem;
      border-radius: 4px;
      background-color: #fff;
      line-height: .88rem;
      text-align: center;
      box-shadow: 1px 1px 5px  rgba(0, 0, 0, .09);
      -webkit-border-radius: 4px;
      margin: .47rem auto 0;
      color: #3A75B9;
      font-size: .34rem;
    }
    .weui-tabbar__item.weui-bar__item_on .weui-tabbar__label {
      color: #0063AE;
    }
  }
</style>

